
OBJS := classet.o\
	hack80d1c58.o\
	hack80D2868.o


ROM := fe8n4.gba

CC := E:/msys2/home/yami/src/mamedev/devkitARM-r54-3-win32.pkg.tar/devkitARM-r54-3-win32.pkg/opt/devkitpro/devkitARM/bin/arm-none-eabi-gcc
OBJCOPY := E:/msys2/home/yami/src/mamedev/devkitARM-r54-3-win32.pkg.tar/devkitARM-r54-3-win32.pkg/opt/devkitpro/devkitARM/bin/arm-none-eabi-objcopy

#先生成elf

elf:$(OBJS)
	$(CC) $(^) -o hack.elf -nostdlib -Thack.ld
	$(OBJCOPY) hack.elf -O binary hack.bin
	lua dumpj.lua JMP.make
	lua write.lua 0x804FB30 04 $(ROM)
	make -C . write WRITE=1

ifdef WRITE
include JMP.make
endif

write:build_jmp
	lua write.lua 0x09000000 hack.bin $(ROM)


clean:
	-rm $(OBJS)

%.o:%.s
	$(CC) -c $(<) -o $(@)

%.o:%.c
	$(CC) -c $(<) -o $(@) -mthumb -O2
